import 'package:aichat_flutter_wallet/module/module_browser/widget/common_widget.dart';
import 'package:aichat_flutter_wallet/module_common/widgets/button/bottom_button.dart';
import 'package:aichat_flutter_wallet/module_common/widgets/dialog/bottom_sheet_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lib_util/utils/utils.dart';

class DappAddTokenWidget extends StatefulWidget {
  String symbol;
  String contract;
  String decimals;
  DappAddTokenWidget(
      {super.key,
      this.symbol = '--',
      this.contract = '--',
      this.decimals = '18'});

  @override
  State<DappAddTokenWidget> createState() => _DappAddTokenWidgetState();
}

class _DappAddTokenWidgetState extends State<DappAddTokenWidget> {
  @override
  Widget build(BuildContext context) {
    return BottomSheetWidget(
      expand: false,
      title: 'Add Token',
      child: Padding(
        padding: EdgeInsets.only(left: 20, right: 20, bottom: 20),
        child: Column(
          children: [
            Row(children: [
              Image.asset(
                'assets/images/dapp/warn.png',
                width: 20.w,
                height: 20.w,
              ),
              SizedBox(
                width: 7.w,
              ),
              Text('Warning')
            ]),
            SizedBox(
              height: 15.w,
            ),
            CommonWidgetUtil.tipWidget(
                'Anyone can create a token, including keeping the same name and description.'),
            SizedBox(
              height: 10.w,
            ),
            CommonWidgetUtil.tipWidget(
                'The only way to distinguish a token is its contract address.'),
            SizedBox(
              height: 10.w,
            ),
            CommonWidgetUtil.tipWidget(
                'Please ensure this is the token you want and bear the risk yourself. '),
            SizedBox(
              height: 25.w,
            ),
            // contentCoinWidget('', '')
            CommonWidgetUtil.contentItemWidget(
                'Token Decimals', Text(widget.decimals)),
            SizedBox(
              height: 10.w,
            ),
            CommonWidgetUtil.contentItemWidget(
                'Token Symbol', Text(widget.symbol)),
            SizedBox(
              height: 10.w,
            ),
            CommonWidgetUtil.contentItemWidget(
                'Contract Address', Text(Utils.formatAddress(widget.contract))),
            SizedBox(
              height: 20.w,
            ),
            BottomBtn(
                textList: ['Agree Add'],
                onConfirm: () {
                  Navigator.of(context).pop(true);
                })
          ],
        ),
      ),
    );
  }

  Widget contentCoinWidget(String image, String text) {
    return Row(children: [
      Image.asset(
        image.isNotEmpty && image != null ? image : 'assets/icon/BNB.png',
        width: 20.w,
        height: 20.w,
      ),
      SizedBox(width: 6.w),
      Text('BNB')
    ]);
  }
}
